import { defineStore } from 'pinia'
import { ref } from 'vue'

export const useConsultStore = defineStore(
	'consult',
	() => {
		// 保存consult数据
		const consult = ref({})
		const setConsult = (val) => {
			// console.log(val, 22222)
			consult.value.illnessTime = val.illnessTime
			consult.value.illnessDesc = val.illnessDesc
			consult.value.consultFlag = val.consultFlag
			val.pictures.forEach(item => {
				console.log(item)
			})
			consult.value.pictures = val.pictures
		}
		// 存科室ID
		const setDepId = (val) => {
			consult.value.depId = val
		}
		
		const setPatientId = (val) => consult.value.patientId = val
		// 存问诊的类型
		const setType = val => consult.value.type = val
		const setIllnessType = val => consult.value.illnessType = val
		
		const clearConsult = () => consult.value = {}
		return {
			consult,
			setConsult,
			setDepId,
			setType,
			setIllnessType,
			clearConsult,
			setPatientId
		}
	},
	{
		persist: {
			storage: {
				setItem: (key, value) => {
					uni.setStorageSync(key, value)
				},
				getItem: (key) => {
					return uni.getStorageSync(key)
				}
			}
		}
	}
)
